<?php $this->load->view('layout/header'); ?>
    <div id="container">
        <!--查询表单开始-->
        <div id="DivQuery">
            <div id="floatBoxBg" style="filter: alpha(opacity=0); opacity: 0;">
            </div>
            <div id="floatBox" class="floatBox">
                <div id="drag" class="title" onmousedown="DragDialog()">
                    <h4>设置</h4>
                    <span>关闭</span></div>
                <div class="content">
                    <form action="<?php echo b_url('wechat/setmemo')?>" method="post">
                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_query">
                            <tr class="table_query_row">
                                <td style="width: 15%" align="right">备注名：</td>
                                <td><input name="memo" type="text" id="txtLimitName" /></td>
                                <input type="hidden" name="userId" id="userId">
                            </tr>
                            <tr class="table_query_btn">
                                <td align="right" style="width: 15%"></td>
                                <td>
                                    <input type="submit" name="btnQuery" value="保存" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;btnQuery&quot;, &quot;&quot;, false, &quot;&quot;, &quot;SysLimit.aspx&quot;, false, false))" id="btnQuery" />
                                    <input type="button" value="返回" onclick="javascript:HiddenSearchDialog();" />
                                </td>
                                <td align="right" style="width: 15%"></td>
                                <td></td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>
        </div>
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_op">
            <tr>
                <td>
                    操作选项：移动分组--
                    <select name="toGroup" id="new_group" onchange="move_group()">
                        <option value="">请选择</option>
                        <?php foreach($group as $k=>$v) : ?>
                            <option value="<?php echo $v['groupid']; ?>"><?php echo $v['groupname']; ?></option>
                        <?php endforeach ; ?>
                    </select>
                    <a href="<?php echo b_url('wechat/member_synoc')?>">同步用户</a>
                </td>
            </tr>
        </table>
        <!--操作选项结束-->
        <!--列表开始-->
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_list" id="TbList">
            <tr class="table_list_title">
                <td style="width: 2%">
                    <input type="checkbox" name="checkbox" value="checkbox" onclick="javascript:checkAll(this,'weixinUserID')" />
                </td>
                <td style="width: 10%" onclick="javascript:GoTo('?OrderKey=SysLimitID&AscDesc=desc&txtLimitName=&txtLimitValue=&txtComment=&txtListID=&txtAdminID=&txtAddTime=&drpIsClose=&page=1')" title="点击排序">
                    自动编号
                </td>
                <td style="width: 10%" onclick="javascript:GoTo('?OrderKey=LimitName&AscDesc=desc&txtLimitName=&txtLimitValue=&txtComment=&txtListID=&txtAdminID=&txtAddTime=&drpIsClose=&page=1')" title="点击排序">
                    用户名
                </td>
                <td style="width: 10%" onclick="javascript:GoTo('?OrderKey=LimitName&AscDesc=desc&txtLimitName=&txtLimitValue=&txtComment=&txtListID=&txtAdminID=&txtAddTime=&drpIsClose=&page=1')" title="点击排序">
                    OpenID
                </td>
                <td style="width: 10%" onclick="javascript:GoTo('?OrderKey=LimitName&AscDesc=desc&txtLimitName=&txtLimitValue=&txtComment=&txtListID=&txtAdminID=&txtAddTime=&drpIsClose=&page=1')" title="点击排序">
                    所属分组
                </td>
                <td style="width: 10%" onclick="javascript:GoTo('?OrderKey=AddTime&AscDesc=desc&txtLimitName=&txtLimitValue=&txtComment=&txtListID=&txtAdminID=&txtAddTime=&drpIsClose=&page=1')" title="点击排序">
                    操作
                </td>
            </tr>
            <?php foreach($member as $k=>$v) : ?>
                <tr class="table_list_row_normal">
                    <td style="width: 2%">
                        <input name="weixinUserID" type="checkbox"  value="<?php echo $v['weixinUserID']?>" />
                    </td>
                    <td style="width: 10%">
                        <?php echo $v['weixinUserID']?>
                    </td>
                    <td style="width: 10%">
                        <?php echo $v['nickname']?>
                    </td>
                    <td style="width: 10%">
                        <?php echo $v['openid']?>
                    </td>
                    <td style="width: 10%">
                        <?php echo $v['groupname']?>
                    </td>
                    <td style="width: 10%">
                        <a href="javascript:;" onclick="set_memo(<?php echo $v['weixinUserID']; ?>)">设置备注名</a>
                    </td>
                </tr>
            <?php endforeach ; ?>
        </table>
        <!--列表结束-->
        <!--分页开始-->
        <?php $pagination->show();?>
        <!--分页结束-->
    </div>
    <script src="/static/bk/js/table.js" type="text/javascript"></script>
<?php $this->load->view('layout/footer'); ?>

<script type="text/javascript">

    function set_memo(id){
        SearchDialog();
        $('#userId').val(id);
    }

    function move_group(){
        var new_group = $("#new_group").val();
        var id = 0;
        var obj = $("input[name=weixinUserID]");
        obj.each(function(){
            if($(this).attr('checked') != undefined){
                id += ','+$(this).val();
            }
        });
        $.ajax({
            type: "POST",
            url: "<?php echo b_url('wechat/move_group')?>",
            data: {id:id,new_group:new_group},
            success: function(){

            }});
//        window.location.reload();
        alert('移动分组成功');
        window.location.reload();
    }
</script>